//
//  BluetoothCenter+Tips.m
//  Holyiot-DFU
//
//  Created by bill on 2022/2/23.
//

#import "BluetoothCenter+Tips.h"

@implementation BluetoothCenter (Tips)
-(void)parseDataWithType:(unsigned char *)data_bytes value:(NSInteger)value
{
    //判断类型
    //密码校验
    if (data_bytes[1]==0x00) {
        
        if (value==0) {
//                    [MBProgressHUD showSuccess:@"The password is correct"];
            [LBHud showText:@"The password is correct"];
            if ([self.delegate respondsToSelector:@selector(verifyPwdSuccess)]) {
                [self.delegate verifyPwdSuccess];
            }
        }else{
//                    [MBProgressHUD showSuccess:@"The password is wrong!"];
            [MBProgressHUD showError:@"The password is wrong!"];
        }
    }
    if (data_bytes[1]==0x01) {
        //改密码
        if (value==0) {
            NSLog(@"修改密码成功...");
//                    [MBProgressHUD showSuccess:@"Modify password success!"];
            [LBHud showText:@"Modify password success!"];
            
        }else{
            NSLog(@"修改密码失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify password fail!"];
            [LBHud showText:@"Modify password fail!"];
        }
    }
    //修改uuid
    if (data_bytes[1]==0x02) {
        if (value==0) {
            NSLog(@"修改uuid成功...");
//                    [MBProgressHUD showSuccess:@"Modify uuid success!"];
            [LBHud showText:@"Modify uuid success!"];
        }else{
            NSLog(@"修uuid失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify uuid fail!"];
            [LBHud showText:@"Modify uuid fail!"];
        }
    }
    if (data_bytes[1]==0x03) {
        //改major
        if (value==0) {
            NSLog(@"修改major成功...");
//                    [MBProgressHUD showSuccess:@"Modify major success!"];
            [LBHud showText:@"Modify major success!"];
        }else{
            NSLog(@"修改major失败!!!");
//                    [MBProgressHUD showError:@"Modify major fail!"];
            [LBHud showText:@"Modify major fail!"];
        }
    }
    if (data_bytes[1]==0x04) {
        //改minor
        if (value==0) {
            NSLog(@"修改minor成功...");
//                    [MBProgressHUD showSuccess:@"Modify minor success!"];
            [LBHud showText:@"Modify minor success!"];
        }else{
            NSLog(@"修改minor失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify minor fail!"];
            [LBHud showText:@"Modify minor fail!"];
        }
    }
    if (data_bytes[1]==0x05) {
        //蓝牙名称
        if (value==0) {
            NSLog(@"修改蓝牙名称成功...");
//                    [MBProgressHUD showSuccess:@"Modify device name success!"];
            [LBHud showText:@"Modify device name success!"];
        }else{
            NSLog(@"修改蓝牙名称失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify device name fail!"];
            [LBHud showText:@"Modify device name fail!"];
        }
    }
    if (data_bytes[1]==0x06) {
        //修改发射功率
        if (value==0) {
            NSLog(@"修改发射功率成功...");
//                    [MBProgressHUD showSuccess:@"Modify tx power success!"];
            [LBHud showText:@"Modify tx power success!"];
        }else{
            NSLog(@"修改发射功率失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify tx power fail!"];
            [LBHud showText:@"Modify tx power fail!"];
        }
    }
    if (data_bytes[1]==0x07) {
        //修改广播间隔
        if (value==0) {
            NSLog(@"修改广播间隔成功...");
//                    [MBProgressHUD showSuccess:@"Modify AD_interval success!"];
            [LBHud showText:@"Modify AD_interval success!"];
        }else{
            NSLog(@"修改广播间隔失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify AD_interval fail!"];
            [LBHud showText:@"Modify AD_interval fail!"];
        }
    }
    if (data_bytes[1]==0x08) {
        //修改一米处rssi
        if (value==0) {
            NSLog(@"修改一米处rssi成功...");
//                    [MBProgressHUD showSuccess:@"verify success!"];
            [LBHud showText:@"verify success!"];
        }else{
            NSLog(@"修改一米处rssi失败!!!");
//                    [MBProgressHUD showSuccess:@"verify fail!"];
            [LBHud showText:@"verify fail!"];
        }
    }
    if (data_bytes[1]==0x09) {
        //修改MAC地址
        if (value==0) {
            NSLog(@"修改MAC地址成功...");
//                    [MBProgressHUD showSuccess:@"Modify MAC success!"];
            [LBHud showText:@"Modify MAC success!"];
        }else{
            NSLog(@"修改MAC地址失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify MAC fail!"];
            [LBHud showText:@"Modify MAC fail!"];
        }
    }
    if (data_bytes[1]==0x0b) {
        //自定义广播数据
        if (value==0) {
            NSLog(@"修改自定义广播数据成功...");
//                    [MBProgressHUD showSuccess:@"Modify ADV package success!"];
            [LBHud showText:@"Modify ADV package success!"];
        }else{
            NSLog(@"修改自定义广播数据失败!!!");
//                    [MBProgressHUD showSuccess:@"Modify ADV package fail!"];
            [LBHud showText:@"Modify ADV package fail!"];
        }
    }
    if (data_bytes[1]==0x20||data_bytes[1]==0x21||data_bytes[1]==0x22||data_bytes[1]==0x23) {
        //自定义广播数据
        if (value==0) {
            //打开/关闭UID 广播成功
            [LBHud showText:@"success!"];
        }else{
            //打开/关闭UID 广播失败
//                    [MBProgressHUD showSuccess:@"Modify ADV package fail!"];
            [LBHud showText:@"fail!"];
        }
    }
    if (data_bytes[1]==0x24) {
        //修改UID广播名称
        if (value==0) {
            //
            [LBHud showText:@"Modify UID adv name success!"];
        }else{
            [LBHud showText:@"Modify UID adv name fail!"];
        }
    }
    if (data_bytes[1]==0x25) {
        //修改UID ID Namespace
        if (value==0) {
            //
            [LBHud showText:@"Modify UID ID Namespace success!"];
        }else{
            [LBHud showText:@"Modify UID ID Namespace fail!"];
        }
    }
    if (data_bytes[1]==0x26) {
        //修改UID ID Instance
        if (value==0) {
            //
            [LBHud showText:@"Modify UID ID Instance success!"];
        }else{
            [LBHud showText:@"Modify UID ID Instance fail!"];
        }
    }
    if (data_bytes[1]==0x27) {
        //修改URL 广播名称
        if (value==0) {
            //
            [LBHud showText:@"Modify URL adv name success!"];
        }else{
            [LBHud showText:@"Modify URL adv name fail!"];
        }
    }
    if (data_bytes[1]==0x28) {
        //修改URL 前缀
        if (value==0) {
            //
            [LBHud showText:@"Modify URL prefix success!"];
        }else{
            [LBHud showText:@"Modify URL prefix fail!"];
        }
    }
    if (data_bytes[1]==0x29) {
        //修改URL 内容
        if (value==0) {
            //
            [LBHud showText:@"Modify URL content success!"];
        }else{
            [LBHud showText:@"Modify URL content fail!"];
        }
    }
    if (data_bytes[1]==0x2a) {
        //修改URL 后缀
        if (value==0) {
            [LBHud showText:@"Modify URL subfix success!"];
        }else{
            [LBHud showText:@"Modify URL subfix fail!"];
        }
    }
    if (data_bytes[1]==0x2b) {
        //修改 TLM 广播名称
        if (value==0) {
            //
            [LBHud showText:@"Modify TLM adv name success!"];
        }else{
            [LBHud showText:@"Modify TLM adv name fail!"];
        }
    }
    if (data_bytes[1]==0x2c) {
        //修改 TLM 版本
        if (value==0) {
            //
            [LBHud showText:@"Modify TLM version success!"];
        }else{
            [LBHud showText:@"Modify TLM version fail!"];
        }
    }
    if (data_bytes[1]==0x2d) {
        //修改 EID 广播名称
        if (value==0) {
            //
            [LBHud showText:@"Modify EID adv name success!"];
        }else{
            [LBHud showText:@"Modify EID adv name fail!"];
        }
    }
    if (data_bytes[1]==0x2e) {
        //修改 EID Encrypted ID
        if (value==0) {
            //
            [LBHud showText:@"Modify EID Encrypted ID success!"];
        }else{
            [LBHud showText:@"Modify EID Encrypted ID fail!"];
        }
    }
    if (data_bytes[1]==0x2f) {
        //切换广播模式
        if (value==0) {
            //
            [LBHud showText:@"success!"];
            [[BluetoothCenter shareInstance]stopScand];
            self.deviceType = self.willChangeType;
            if ([self.delegate respondsToSelector:@selector(deviceDidUpdateInfo:)]) {
                [self.delegate deviceDidUpdateInfo:@{@"device_switch":@"0"}];
            }
        }else{
            [LBHud showText:@"fail!"];
            if ([self.delegate respondsToSelector:@selector(deviceDidUpdateInfo:)]) {
                [self.delegate deviceDidUpdateInfo:@{@"device_switch":@"1"}];
            }
        }
    }
}
@end
